<%-- 
    Document   : thaoluan
    Created on : 30-09-2011, 23:04:12
    Author     : Mr-Nguyen
--%>

<%@page import="DatabasePOJO.user"%>
<%@page import="DAO.binhLuanDAO"%>
<%@page import="DatabasePOJO.binhluan"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%
    user us = new user();
    us.setMauser("2");
    if(session.getAttribute("login")!= null)
        us = (user)session.getAttribute("login");
    String masp = request.getParameter("masp");
    if(request.getParameter("btnbinhluan") != null){
        String value = request.getParameter("txtchuoibl");
        binhluan addbl = new binhluan();
        addbl.setBinhLuan(value);
        addbl.setMaSanPham(masp);
        addbl.setMaUser(us.getMauser());
        binhLuanDAO.addBinhLuan(addbl);
    }
    ArrayList<binhluan> arrbl = new ArrayList<binhluan>();
    arrbl = binhLuanDAO.getBinhLuanAtSanPhamID(masp);
%>
<form action="" method="post" name="frm1" id="frm1">
        <table width="100%" border="0">
  <tr>
    <td width="16%" height="111">user name</td>
    <td width="84%"><textarea name="txtchuoibl" id="textfield" style="height:100px;width:100%"></textarea></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="right">
    <input name="btnbinhluan" type="Submit"  onclick="Them();" value="Bình luận"/>
    </td>
  </tr>
  <%
    for(int i = 0;i<arrbl.size();i++){
    binhluan bl = new binhluan(arrbl.get(i));
%>
  <tr>
     <hr></hr>
    <td height="100"><%= bl.getMaUser() %></td>
    <td>&nbsp;
    <div name="tl" id="tl" >
    <%= bl.getBinhLuan() %>
    <hr></hr>
    </div>
    </td>
  </tr>
  <%}%>
</table>
</form>
